package com.itmuch.providerdemo;

import com.google.common.collect.Maps;
import com.itmuch.providerdemo.feign.FeignRemoteException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(FeignRemoteException.class)
    @ResponseBody
    public Map<String, String> error(FeignRemoteException e) {
        HashMap<String, String> map = Maps.newHashMap();
        map.put("errorMsg", e.getMessage());
        return map;
    }
}
